public class AccountThread implements Runnable{
    private Account account = new Account();
    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            try {
                Thread.sleep(500);
                depoist(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public void depoist(int money){
        synchronized (account){
            System.out.println(Thread.currentThread().getName() + "开始存款");
            account.depoist(money);
            System.out.println(Thread.currentThread().getName() + "完成存款");
            System.out.println("存款为" + account.getBalance());

        }
    }
}